<script language="javascript" src="<?php echo JQUERYUI ?>jquery.ui.mouse.min.js"></script>
<script language="javascript" src="<?php echo JQUERYUI ?>jquery.ui.draggable.min.js"></script>
<script language="javascript" src="<?php echo JQUERYUI ?>jquery.ui.position.min.js"></script>
<script language="javascript" src="<?php echo JQUERYUI ?>jquery.ui.resizable.min.js"></script>
<script language="javascript" src="<?php echo JQUERYUI ?>jquery.ui.dialog.min.js"></script>
<script>
	$(document).ready(function() {
		$( ".date" ).datepicker();
		$( ".date" ).datepicker( "option", "dateFormat", "dd-mm-yy");
		$( "#tgl_awal" ).change(function(){
			location.href = "<?php echo LAPKAN ?>list_result/"+$('#tgl_awal').val()+"/"+$('#tgl_akhir').val();
		});
		$( "#tgl_akhir" ).change(function(){
			location.href = "<?php echo LAPKAN ?>list_result/"+$('#tgl_awal').val()+"/"+$('#tgl_akhir').val();
		});
		list_table = $('#list_laporan_kendaraan').dataTable({
			"bFilter" : true,
			"bJQueryUI" : true,
			"aLengthMenu": [[10,25,50, 100, -1], [10,25,50,100, "Semua"]],
			"sPaginationType": "full_numbers",
			"oLanguage": {
				"sLengthMenu": "Menampilkan _MENU_ data",
				"sZeroRecords": "Belum ada data penerimaan kasir yang tersimpan",
				"sInfoFiltered": "(Hasil filter dari _MAX_ yang didapat)"
			}
		});
		$('#list_laporan_kendaraan_filter').hide();
		$('#filter_cabang').change( function () {
			asal = $( '#filter_cabang' ).val();
			if(asal=='SEMUA'){
				list_table.fnFilter( '',2 );
			}else{
				list_table.fnFilter( asal,2 );
			}
		} );
		$( "#cetak_pdf" ).click(function(){
			tgl_awal = $( "#tgl_awal" ).val();
			tgl_akhir = $( "#tgl_akhir" ).val();
			cabang = $( "#filter_cabang" ).val();
			location.href="<?php echo LAPKAN ?>cetak_pdf/"+tgl_awal+"/"+tgl_akhir+"/"+cabang;
		});
		$( "#cetak_excel" ).click(function(){
			tgl_awal = $( "#tgl_awal" ).val();
			tgl_akhir = $( "#tgl_akhir" ).val();
			cabang = $( "#filter_cabang" ).val();
			location.href="<?php echo LAPKAN ?>cetak_excel/"+tgl_awal+"/"+tgl_akhir+"/"+cabang;
		});
	} );
</script>
<?php
$data['cur_parent_menu']='laporan';
$data['cur_selected_menu']='lapkan';
$this->load->view('template/menu_view',$data);
?>
<br/><br/><br/><br/><br/><br/>
<table width="1000" align="center">
	<tr>
		<td width="500">
			<?php
			$opt['SEMUA'] = 'SEMUA';
			$opt = array_merge($opt, $filter_cabang['nama_cabang']);
			?>
			Filter cabang : <?php echo form_dropdown('cabang', $opt, '', 'id="filter_cabang"') ?>
		</td>
		<td width="500" align="left">
			Tgl Awal : <input type="text" class="date" id="tgl_awal" value="<?php echo $tgl_awal ?>"/>
			Tgl Akhir : <input type="text" class="date" id="tgl_akhir" value="<?php echo $tgl_akhir ?>"/>
		</td>
	</tr>
</table>
<br/>
Cetak : <span class="clicked" id="cetak_pdf">PDF </span><span class="clicked" id="cetak_excel">Excel</span>
<br/>
<table id="list_laporan_kendaraan" width="100%" align="center" border="0">
	<thead>
		<tr>
			<th>No.</th>
			<th>No. Polisi</th>
			<th>Cabang</th>
			<th>Total Keberangkatan</th>
			<th>Total Tiket</th>
			<th>Total Tiket Void</th>
			<th>Total Omset</th>
			<th>Total Discount</th>
			<th>Total Fee Agen</th>
			<th>Total Void</th>
			<th>Total Biaya Langsung</th>
			<th>Total Setor</th>
			<th>Total Biaya Awal</th>
			<th>Total Laba Kotor</th>
                        <th>Action</th>
		</tr>
	</thead>
	<tbody>
		<?php for ($i = 0; $i < count($list_result); $i++) { ?>
			<tr>
				<td align="center"><?php echo ($i+1) ?></td>
				<td align="center"><?php echo $list_result[$i]['NoPol'] ?></td>
				<td align="center"><?php echo $cabang_setoran[$i]['cabang_keberangkatan'] ?></td>
				<td align="center"><?php echo $list_result[$i]['jumlah_nopol'] ?></td>
				<td align="center"><?php echo $setoran[$i]['total_penumpang'] ?></td>
				<td align="center"><?php echo $setoran[$i]['tiket_void'] ?></td>
				<td align="center">Rp. <?php echo number_format($setoran[$i]['total_omset'],0,',','.') ?></td>
				<td align="center">Rp. <?php echo number_format($setoran[$i]['total_discount'],0,',','.') ?></td>
				<td align="center">Rp. <?php echo number_format($setoran[$i]['fee_agen'],0,',','.') ?></td>
				<td align="center">Rp. <?php echo number_format($setoran[$i]['total_void'],0,',','.') ?></td>
				<td align="center">Rp. <?php echo number_format($setoran[$i]['jumlah'],0,',','.') ?></td>
				<td align="center">Rp. <?php echo number_format($setoran[$i]['total_setoran'],0,',','.') ?></td>
				<td align="center">Rp. <?php echo number_format($op_awal[$i]['jumlah'],0,',','.') ?></td>
				<td align="center">Rp. <?php echo number_format($setoran[$i]['total_laba'],0,',','.') ?></td>
                                <td align="center">
                            <a href="<?php echo LAPKAN ?>grafik_harian_produk_nopol/<?php echo $list_result[$i]['NoPol']?>">Grafik Produktivitas Bulanan</a>|
                            <a href="<?php echo LAPKAN ?>grafik_bulanan_produk_nopol/<?php echo $list_result[$i]['NoPol']?>">Grafik Produktivitas Tahunan</a></td>
			</tr>
		<?php }
		?>
	</tbody>
</table>